package com.xuelang.pipeline.app.pipeline;

import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.pipeline.dto.PipelineInstanceConfigDTO;
import com.xuelang.pipeline.client.pipeline.dto.PipelineInstanceDTO;
import com.xuelang.pipeline.client.pipeline.dto.PipelineInstanceQuery;

import java.util.List;

/**
 * <p>流水线实例服务类</p>
 *
 * @author : yixin.lys
 * @date : 2024-06-19 11:32
 **/
public interface PipelineInstanceService {

    /**
     * 根据流水线code分页获取流水线实例
     *
     * @param query
     * @return
     */
    PageRecord<PipelineInstanceDTO> page(PageParam<PipelineInstanceQuery> query);

    /**
     * 根据流水线code获取流水线实例
     *
     * @param pipelineCode
     * @return
     */
    List<PipelineInstanceDTO> listByPipelineCode(String pipelineCode);

    /**
     * 根据
     * @param componentLabel
     * @return
     */
    List<PipelineInstanceDTO> listByComponentLabel(String componentLabel);


    /**
     * 新增流水线实例
     *
     * @param pipelineInstance
     */
    void add(PipelineInstanceDTO pipelineInstance);


    /**
     * 更新流水线实例
     *
     * @param pipelineInstance
     */
    void update(PipelineInstanceDTO pipelineInstance);


    /**
     * 根据id批量删除
     *
     * @param idList
     */
    void removeByIds(List<String> idList);

    /**
     * 根据流水线code批量删除
     *
     * @param codeList
     */
    void removeByCodes(List<String> codeList);

    /**
     *  根据pipelineCode获取流水线实例配置
     * @param pipelineCode
     * @return
     */
    PipelineInstanceConfigDTO getPipelineInstanceConfig(String pipelineCode);

    /**
     *  根据code获取流水线实例配置
     * @param flag  code  1  是传instanceCode,  2是传pipelineCode
     * @return
     */
    PipelineInstanceConfigDTO getInstanceConfig(String flag,String code);

    /**
     *  根据任务实例code 来审批
     * @param type
     * @param taskUuid
     * @return
     */
    ApiResult<Boolean> instanceApprove(String type, String taskUuid);
}
